//
//  MainCollectionViewCell.m
//  CoJellyCartoon
//
//  Created by kingbw on 16/4/1.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "MainCollectionViewCell.h"
#import "MainTableViewCell.h"
@implementation MainCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.dataSource = [NSMutableArray arrayWithCapacity:0];
        
        self.table = [[CJBaseTableView alloc] initWithFrame:self.contentView.frame style:UITableViewStylePlain];
        self.table.delegate = self;
        self.table.dataSource = self;
        self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self.table registerClass:[MainTableViewCell class] forCellReuseIdentifier:@"MainTableViewCellIdentifier"];
        [self addSubview:self.table];
        
        
    }
    return self;
}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainTableViewCellIdentifier"];
    self.searchModel = self.dataSource[indexPath.row];
    cell.search = self.searchModel;
    
    cell.numberLabel.text = [NSString stringWithFormat:@"%ld.", indexPath.row + 1];
    if (indexPath.row < 3) {
        cell.numberLabel.textColor = [UIColor colorWithRed:247 / 255.0 green:88 / 255.0 blue:136 / 255.0 alpha:1];
    } else {
        cell.numberLabel.textColor = [UIColor blackColor];
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.delegate jumpToController:indexPath.row];
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return ScreenHeight * 120 / 736;
}

- (void)setDataSource:(NSMutableArray *)dataSource {
    _dataSource = dataSource;
    [self.table reloadData];
}

@end
